<?php

namespace app\controller\bossManager;

use app\validate\PageValidate;
use app\validate\DeviceBaseValidate;
use app\service\DeviceBaseService;

class DeviceBaseController extends WebBossController{
    public function initValidate(){        
        $this->validate = new DeviceBaseValidate();
    }

    public function list_action(){  
        $input = $this->check();     
        $page = $this->check('pageInfo',null,(new PageValidate()));        
        $data = DeviceBaseService::getListInfo($input,$page);
        $total = DeviceBaseService::getListCountInfo($input);
        return self::ok(self::formatPageData($page,$total,$data));    
    }

    public function detail_action(){
        $input = $this->check();
        $data = DeviceBaseService::getDetailInfo($input['id']);
        return self::ok($data); 
    }

    public function async_action(){
        $input = $this->check('detail');
        $data = DeviceBaseService::async($input['id'],true);
        return self::ok($data); 
    }

    public function set_action(){
        $input = $this->check();
        $data = DeviceBaseService::edit($input);
        return self::ok($data); 
    }
}